-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[camera_avfoundation] Wrappers swift migration - part 4 #10440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[camera_avfoundation] Wrappers swift migration - part 4 #10440
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request continues the migration of Objective-C code to Swift by converting FLTCaptureConnection, FLTCaptureDeviceFormat, and FLTAssetWriter from wrapper classes to Swift protocols. This is a solid architectural improvement that makes the code more idiomatic and type-safe. The changes are consistently applied throughout the codebase, including tests and mocks. I have one minor suggestion to further align the code with Swift conventions.
.../camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/CaptureOutput.swift
Outdated
Show resolved
Hide resolved
c962452 to
7948414
Compare
|
@hellohuanlin pls take a look at this PR again when you have some time |
hellohuanlin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. Overall looks good.
| /// A mock implementation of `FrameRateRange` that allows mocking the class properties. | ||
| final class MockFrameRateRange: NSObject, FrameRateRange { | ||
| var minFrameRate: Float64 | ||
| var maxFrameRate: Float64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this change required?
| return FLTDefaultCaptureConnection(connection: connection) | ||
| func connection(with mediaType: AVMediaType) -> CaptureConnection? { | ||
| let connection: AVCaptureConnection? = connection(with: mediaType) | ||
| return connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can be 1 line
| return FLTDefaultCaptureConnection(connection: connection) | ||
| func connection(with mediaType: AVMediaType) -> CaptureConnection? { | ||
| let connection: AVCaptureConnection? = connection(with: mediaType) | ||
| return connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can be 1 line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you need infer the type, you can do return AVCaptureConnection.connection(with: mediaType)
| // https://github.com/flutter/flutter/issues/132016 | ||
| // https://github.com/flutter/flutter/issues/151319 | ||
| videoWriter?.startWriting() | ||
| // Result ignored in line with the Objective-C implementation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also comment what the result is? also this comment is confusing because there wont' be any objc implementation after the migration
| videoAdaptor?.append(nextBuffer!, withPresentationTime: nextSampleTime) | ||
| if videoWriterInput?.isReadyForMoreMediaData ?? false { | ||
| // Result ignored in line with the Objective-C implementation | ||
| let _ = videoAdaptor?.append(nextBuffer!, withPresentationTime: nextSampleTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
Migrates camera wrappers as part of flutter/flutter#119109
This PR migrates wrappers to Swift:
FLTCaptureConnectionFLTCaptureDeviceFormatFLTAssetWriterIn line with Swift conventions, the
FLTprefixes are removed. TheDefaultclass implementations are replaced with protocol conformance on baseAVclasses.Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3